package com.mijie.homi.ns.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mijie.homi.common.domain.Upgrade;
import com.mijie.homi.ns.dao.UpgradeDao;
import com.mijie.util.Helper;

@Service
public class UpgradeService {

	@Autowired
	private UpgradeDao dao;
	
	public Upgrade getUpgrade(String osTpye,String versionName){
		Upgrade upgrade = null;
		if(osTpye.equalsIgnoreCase("android")) upgrade = dao.getAndroidUpgrade();
		else if(osTpye.equalsIgnoreCase("ios")) upgrade =  dao.getIphoneUpgrade();
		if(upgrade!=null){
			if(!Helper.checkUpgrade(versionName, upgrade.getVersionName())) upgrade = null;
		}
		return upgrade;
	}
}
